package 剑指offer;

public class 剑指Offer57和为s的两个数字 {
    public int[] twoSum(int[] nums, int target) {
        int left = 0;
        int right = nums.length - 1;
        int[] arr = new int[2];
        while(left <= right){
            if(nums[left] + nums[right] < target ){
                left++;
            }else  if(nums[left] + nums[right] > target ){
                right--;
            }else{
                arr[0] = nums[left];
                arr[1] = nums[right];
                return arr;
            }
        }
        return arr;
    }
}
